package ${package.Controller};


import com.fyl.core.advance.constant.enums.CommonResponseEnum;
import com.fyl.core.response.RS;
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
import ${package.Entity}.${entity};
import ${package.Service}.${table.serviceName};
</#if>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>

import java.util.Collection;

/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName?default("")?trim?length gt 1>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass}<${table.serviceName}, ${entity}> {
<#else>
public class ${table.controllerName} {
</#if>

    private static final Logger log = LoggerFactory.getLogger(${table.controllerName}.class);

    @PostMapping({"/add"})
    public RS<Void> add(@RequestBody ${entity} entity) {
        return this.baseService.save(entity) ? RS.genSuccess() : RS.genFail(CommonResponseEnum.FAIL);
    }

    @PostMapping({"/update"})
    public RS<Void> update(@RequestBody ${entity} entity) {
        return this.baseService.updateById(entity) ? RS.genSuccess() : RS.genFail(CommonResponseEnum.FAIL);
    }

    @PostMapping({"/delete"})
    public RS<Void> delete(@RequestBody Collection<Long> idList) {
        return this.baseService.removeByIds(idList) ? RS.genSuccess() : RS.genFail(CommonResponseEnum.FAIL);
    }

}
</#if>
